package com.jiyinit.web.core.business.dao;

import com.jiyinit.core.framework.dao.mybatis.base.MybatisDaoContext;
import com.jiyinit.web.core.business.dto.MChatRequest;
import com.jiyinit.web.core.business.entity.TabCoreGroupEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p></p>
 * <p/>
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author zhaolaiwei
 * @version 1.0
 * @date 2017/4/11 17:51
 * @since 1.0
 */
@Repository("core.groupDao")
public class TabCoreGroupDao {

    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(UserGroupDao.class);

    private String SQLID = "core.group.";

    @Autowired
    @Qualifier("core.MybatisDaoContext")
    private MybatisDaoContext mybatisDaoContext;


    public int save(TabCoreGroupEntity group){
        return mybatisDaoContext.save(SQLID+"insertSelective",group);
    }

    public List<TabCoreGroupEntity>  findGroupMember(Integer userId){
        return mybatisDaoContext.findAll(SQLID+"findgroupmember",TabCoreGroupEntity.class,userId);
    }

    public TabCoreGroupEntity selectByPrimaryKey(Integer groupId)
    {
        return mybatisDaoContext.findOne(SQLID + "selectByPrimaryKey", TabCoreGroupEntity.class, groupId);
    }

    public int dissolveGroup(Integer groupId){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("groupId", groupId);
        return mybatisDaoContext.update(SQLID + "dissolveGroup", map);
    }
}
